package cn.com.jslh.boarpro.main.view;

import android.os.Bundle;
import android.support.v7.app.AppCompatActivity;
import android.support.v7.widget.DividerItemDecoration;
import android.support.v7.widget.LinearLayoutManager;
import android.support.v7.widget.RecyclerView;
import android.widget.LinearLayout;

import butterknife.BindView;
import butterknife.ButterKnife;
import butterknife.OnClick;
import cn.com.jslh.boarpro.R;
import cn.com.jslh.boarpro.main.contract.SearchResultContract;
import cn.com.jslh.boarpro.main.presenter.SearchResultPresenterImpl;

public class SearchResultActivity extends AppCompatActivity implements SearchResultContract.View {

    @BindView(R.id.recycleview)
    RecyclerView recycleview;
    @BindView(R.id.layout)
    LinearLayout layout;
    private SearchResultContract.Presenter presenter;

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_search_result);
        ButterKnife.bind(this);
        LinearLayoutManager linearLayoutManager = new LinearLayoutManager(this, LinearLayoutManager.VERTICAL, false);
        recycleview.setLayoutManager(linearLayoutManager);
        recycleview.addItemDecoration(new DividerItemDecoration(this, DividerItemDecoration.VERTICAL));
        new SearchResultPresenterImpl(this, this);
        presenter.setData(getIntent().getStringExtra("json"));
        presenter.setHeader(layout);
        presenter.bindRV(recycleview);
        presenter.start();

    }

    @Override
    public void setPresenter(SearchResultContract.Presenter presenter) {
        this.presenter = presenter;
    }

    @OnClick(R.id.back)
    public void onViewClicked() {
        SearchResultActivity.this.finish();
    }
}
